import { createSlice } from '@reduxjs/toolkit'
// Define the initial state using that type
const initialState = {
  progress: 0,
  progressVisible: false,
  assignName: '',
  assignMobile: ''
}

export const slice = createSlice({
  name: 'common',
  // `createSlice` will infer the state type from the `initialState` argument
  initialState,
  reducers: {
    setProgress: (state, action) => {
      state.progress = action.payload
    },
    setProgressVisible: (state, action) => {
      state.progress = 0
      state.progressVisible = action.payload
    },
    setAssign: (state, action) => {
      state.assignName = action.payload.name
      state.assignMobile = action.payload.mobile
    }
  },
})

export const { setProgress, setProgressVisible, setAssign } = slice.actions

export default slice.reducer